﻿<Window x:Class="ImageProcessing.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:ImageProcessing"
        mc:Ignorable="d"
        Title="MainWindow"
        Height="600"
        Width="960">
    <Window.Resources>
        <local:ModeToVisibilityConverter x:Key="ModeToVisibilityConverter" />
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal">
            <Button Margin="10,20"
                    Padding="10,5"
                    HorizontalAlignment="Left"
                    Content="Chọn ảnh"
                    Command="{Binding BrowseCommand}" />
            <ComboBox SelectedIndex="{Binding Mode, Mode=TwoWay, FallbackValue=0}"
                      Margin="10,20">
                <ComboBoxItem Content="Lọc trung vị" />
                <ComboBoxItem Content="Lọc trung bình" />
                <ComboBoxItem Content="Lọc ngoài" />
            </ComboBox>
            <ComboBox SelectedIndex="{Binding Size, Mode=TwoWay, FallbackValue=0}"
                      Margin="10,20">
                <ComboBoxItem Content="3x3" />
                <ComboBoxItem Content="5x5" />
                <ComboBoxItem Content="7x7" />
            </ComboBox>
            <Button Margin="10,20"
                    Padding="10,5"
                    HorizontalAlignment="Left"
                    Content="Xử lí"
                    Command="{Binding ProcessCommand}" />
            <Button Margin="10,20"
                    Padding="10,5"
                    HorizontalAlignment="Left"
                    Content="Đặt lại"
                    Command="{Binding ResetCommand}" />
            <StackPanel Orientation="Horizontal"
                        Visibility="{Binding Mode, Converter={StaticResource ModeToVisibilityConverter}}">
                <TextBlock Text="Ngưỡng"
                           Margin="10"
                           FontSize="26"
                           VerticalAlignment="Center" />
                <Slider Margin="10"
                        VerticalAlignment="Center"
                        Width="160"
                        Maximum="255"
                        Value="{Binding Threshold, Mode=TwoWay}" />
                <TextBlock Text="{Binding Threshold}"
                           Margin="10"
                           FontSize="26"
                           VerticalAlignment="Center" />
            </StackPanel>
        </StackPanel>
        <Grid Margin="20,0"
              Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Grid>
                <Image Margin="10"
                       Source="{Binding OriginalSource}" />
            </Grid>
            <Grid Grid.Column="1">
                <Image Margin="10"
                       Source="{Binding ProcessedSource}" />
            </Grid>
        </Grid>
        <Grid Grid.Row="2">
            <Button Content="Mở trong cửa sổ mới"
                    Command="{Binding OpenNewWindowCommand}"
                    Margin="10"
                    HorizontalAlignment="Right" />
        </Grid>
    </Grid>
</Window>